package com.uml.umlwork.config.exception;

import com.uml.umlwork.entity.enumeration.GlobalServiceMsgCode;
import com.uml.umlwork.utils.SystemMsgJsonResponse;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 这个用来处理系统抛出的异常,捕获到异常后抛出Json给前端
 * 一切从简
 *
 * @Author Siki
 * @Date 2020/12/11
 */

@RestControllerAdvice
public class ResultExceptionHandler {
//    private static final Logger LOGGER = LoggerFactory.getLogger(ResultExceptionHandler.class);

    /**
     * 处理所有不可知的异常
     *
     * @param e 异常对象
     * @return {@link SystemMsgJsonResponse}
     */
    @ExceptionHandler(Exception.class)
    SystemMsgJsonResponse handleException(Exception e) {
        return SystemMsgJsonResponse.error(GlobalServiceMsgCode.ERROR_FAIL, "错误:" + e.getMessage());
    }

}